#-*- coding: utf8 -*-
from tutor.scripts import *
from tutor.plugins.sympy import *

n_iter = 0
rand_n = lambda: One * oneof(1, 2, 3, 4, 5, 6, 8, 9, 10, 12) / oneof(1, 2, 3, 4, 5, 6, 10)
with display_block('Resultados'):
    while True:
        n_iter += 1
        a = sqrt(rand_n())
        m = rand_n()

        # Respostas
        correta = pi * m * a ** 4 / 12
        densidade = pi * a ** 4 / 12
        jacob = (Eight / 15) * pi * m * a ** (Five / 2)
        jacobDensidade = jacob / m
        cilindro = m * pi * (sqrt(z) * (a - z)).subs({z: a / 2}) ** 2 * a

        # Distratores
        _ans = set([correta, densidade, jacob, jacobDensidade, cilindro])
        _distratores = set()
        if len(_ans) != 5:
            continue
        while len(_distratores) < 5:
            _number = oneof(*_ans) * randint(1, 5) / randint(1, 5)
            if _number not in _ans:
                _distratores.add(_number)
                _ans.add(_number)

        # Previne números grandes
        _cont = False
        for _number in _ans:
            _num, _den = (_number / pi).as_numer_denom()
            if _den > 20 or _num > 50:
                _cont = True
        if _cont:
            continue

        dis1, dis2, dis3, dis4, dis5 = _distratores

        break
